home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Disc to the Future 2
/
Disc to the Future Part II Programmer's Reference (Wayzata Technology)(6013)(1992).bin
/
MAC
/
THINKC
/
3_0
/
OIC_1
/
OIC_SOUR
/
CLASS.C
next >
Wrap
Text File
|
1989-03-05
|
2KB
|
112 lines
/*
* Class - the class class; the default meta-class.
*
* Copyright ⌐ John Wainwright 1988
*
* Supers : None.
*
* Class Vars : None
*
* Class Methods : None
*
* Methods :
*
* print - prints the class name
* supers - list of all the supers for this class.
* subs - list of all the sub-classes for this class.
*/
#include "oic.h"
#include "generics.h"
class Class; /* Class class */
class classes; /* list of all classes */
/* -------------------- Class Instance methods ---------------------------- */
method list
get_supers(list, class)
list list;
class class;
{
register classlist *cl;
for (cl = class->c_superclasses; cl != END; cl = cl->cl_next)
{
if (class != cl->cl_class)
push(list, cl->cl_class);
get_supers(list, cl->cl_class);
}
return list;
}
method object
_supers(self)
register class self;
{
return get_supers(New(List, END), self);
}
method object
_subs(self)
class self;
{
register object list;
register class o;
list = New(List, END);
for (o = classes; o != END; o = o->c_next)
if (o != self && SubClassOf(o, self))
push(list, o);
return list;
}
method object
_cantDo(self, dummy, ap)
class self;
char *dummy;
struct
{
GenericTable *gen;
char *args;
} *ap;
{
gprintf(screen, "** No \"%s\" class method for %s\n", GenericName(ap->gen), self->c_name);
return END;
}
method
_print(self)
class self;
{
gprintf(screen, "%s\n", self->c_name);
}
method object
_repList(self)
class self;
{
return New(String, self->c_name);
}
/* ------------------- Init the Class class ------------------------------- */
/*
* note that Class has already been made - the ONLY function
* that should call this function is InitRootClasses in obj.c
*/
InitClass()
{
AddMethods(Class,
supersGeneric, _supers,
subsGeneric, _subs,
cantDoGeneric, _cantDo,
printGeneric, _print,
repListGeneric, _repList,
END);
}